<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8"/>
	<meta name="keywords" content="line ending, newline, line break, LF, CR, CRLF, NEL, LS, PS"/>
	<link rel="stylesheet" href="../../Shared/sty/standard.css"/>
	<script defer src="../../Shared/js/toc.js"></script>
	
	<title>Handle various types of line endings in CotEditor on Mac</title>
</head>

<body>

<h1>Handle various types of line endings in CotEditor on Mac</h1>

<p>CotEditor can handle various types of line endings. In general, CotEditor uses a single type of line ending set for the document consistently.</p>


<p>CotEditor treats the following characters as line ending delimiters.</p>

<table>
	<caption>Line ending types</caption>
	
	<thead>
		<tr><th>Label</th><th>Unicode name</th><th>Code point</th><th>Metacharacter</th><th>Description</th></tr>
	</thead>
	<tbody>
		<tr><td>LF</td>
			<td>Line Feed</td>
			<td><code>U+000A</code></td>
			<td>\n</td>
			<td>The standard line endings in UNIX and modern macOS.</td>
		</tr>
		
		<tr><td>CR</td>
			<td>Carriage Return</td>
			<td><code>U+000D</code></td>
			<td>\r</td>
			<td>The line ending used in classic Mac OS.</td>
		</tr>
		
		<tr><td>CRLF</td>
			<td class="na">–</td>
			<td><code>U+000D</code> <code>U+000A</code></td>
			<td>\r\n</td>
			<td>The combination of CR and LF line endings. Used mainly in Windows.</td>
		</tr>
	</tbody>
	<tbody>
		<tr><td>NEL</td>
			<td>Next Line</td>
			<td><code>U+0085</code></td>
			<td></td>
			<td>A legacy line ending character used mainly in EBCDIC, a kind of character encoding by IBM. Hidden by default.</td>
		</tr>
		
		<tr><td>LS</td>
			<td>Line Separator</td>
			<td><code>U+2028</code></td>
			<td></td>
			<td>A control character indicating the separator of lines in Unicode. Hidden by default.</td>
		</tr>
		
		<tr><td>PS</td>
			<td>Paragraph Separator</td>
			<td><code>U+2029</code></td>
			<td></td>
			<td>A control character indicating the separator of paragraphs in Unicode. Hidden by default.</td>
		</tr>
	</tbody>
</table>

<p>The latter three types, NEL, LS, and PS, are hardly used in the real world as line ending delimiters. Therefore, CotEditor hides them by default in the line ending choices.</p>

<p><em class="note">Note:</em> Although VT (<code>U+000B</code>) and FF (<code>U+000C</code>) also visually break lines in CotEditor, they aren’t regarded as line endings characters.</p>


<section>
<h2>Set default line endings</h2>

<p>You can set the default line ending type for new documents in Format settings. This setting is used also when the existing document doesn’t have any line endings.</p>
</section>


<section>
<h2>Detect line endings in a document</h2>

<p>CotEditor detects the line ending used in a document automatically. When you open an existing document, the app sets the detected line ending as the line ending for further editing.</p>

<p>If a document has inconsistent line endings, CotEditor automatically alerts and highlights them. For details, see <a href="howto_find_inconsistent_line_endings.html">Find inconsistent line endings</a>.</p>
</section>


<section>
<h2>Inspect the document line ending</h2>

<p>You can inspect the type of line endings used in the document either in the following area:</p>
<ul>
	<li><p>The label of the Line Endings pop-up menu on the right side of the status bar</p></li>
	<li><p>The Document Inspector by choosing View &gt; Inspectors &gt; Document</p></li>
	<li><p>The selection of the Line Endings submenu in the Format menu</p></li>
</ul>
</section>


<section>
<h2>Change the document line ending</h2>

<p>You can change all the line endings in the document to another either in the following area:</p>
<ul>
	<li><p>The Line Endings pop-up menu on the right side of the status bar</p></li>
	<li><p>The Line Endings submenu in the Format menu</p></li>
</ul>

<p>To convert the document line endings to a hidden one, such as NEL, LS, or PS, open the Line Endings menu by pressing the <kbd>Option</kbd> key.</p>
</section>


<section>
<h2>Insert line endings different from document line ending</h2>

<p>In general, CotEditor uses only the document line ending when breaking lines so that you don’t need to care about the difference in the line endings types. Even if you insert text with different line endings in some way, such as by CotEditor script or text replacement using the regular expression, CotEditor implicitly converts all line endings in the text to insert to the line ending in the document.</p>

<p>CotEditor provides the following two ways to insert line endings different from the document’s line ending:</p>

<ul>
	<li><p>Manually enter a line ending character by its <a href="howto_input_unicode.html">Unicode code point</a>.</p></li>
	<li><p>Paste text containing some different line endings with the <a href="howto_paste.html">Paste Exactly command</a>.</p></li>
</ul>
</section>


<section id="cf">
<h2>See also</h2>
<ul>
	<li><a href="howto_find_newline.html">Find or replace a line ending in CotEditor on Mac</a></li>
	<li><a href="howto_find_inconsistent_line_endings.html">Find inconsistent line endings in CotEditor on Mac</a></li>
	<li><a href="howto_input_unicode.html">Enter a character using Unicode code point in CotEditor on Mac</a></li>
	<li><a href="howto_paste.html">Paste text in CotEditor on Mac</a></li>
	<li><a href="settings_format.html">Change Format settings in CotEditor on Mac</a></li>
</ul>
</section>

</body>
</html>
